{extend name="layout:base" /}

{block name="content"}
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <form class="layui-form">
                <input type="hidden" name="id" value="{$article.id}">
                <div class="layui-row layui-col-space10 layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">网站名</label>
                        <div class="layui-input-inline">
                            <input type="text" name="urlName" value="{$article.urlName}" lay-verify="required" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">网址</label>
                        <div class="layui-input-inline">
                            <input type="text" name="url" value="{$article.url}" lay-verify="required" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-row layui-col-space10 layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">网站后台</label>
                        <div class="layui-input-inline">
                            <input type="text" name="urlback" value="{$article.urlback}" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">后台帐号</label>
                        <div class="layui-input-inline">
                            <input type="text" name="urlback_name" value="{$article.urlback_name}" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label">后台密码</label>
                        <div class="layui-input-inline">
                            <input type="text" name="urlback_pwd" value="{$article.urlback_pwd}" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>

                <div class="layui-row layui-col-space10 layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">ftp</label>
                        <div class="layui-input-inline">
                            <input type="text" name="ftp" value="{$article.ftp}"  autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">ftp帐号</label>
                        <div class="layui-input-inline">
                            <input type="text" name="ftp_name" value="{$article.ftp_name}"  autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">ftp密码</label>
                        <div class="layui-input-inline">
                            <input type="text" name="ftp_pwd" value="{$article.ftp_pwd}"  autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-row layui-col-space10 layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">是否封顶</label>
                        <div class="layui-input-inline">
                            <input type="radio" name="istop" value="1" title="是" lay-filter="istop" {if condition="$article.istop==1"}checked{/if}>
                            <input type="radio" name="istop" value="0" title="否" lay-filter="istop" {if condition="$article.istop==0"}checked{/if}>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">封顶金额</label>
                        <div class="layui-input-inline">
                            <input type="text" name="topMoney" value="{$article.topMoney}" id="topMoney" readonly lay-verify="required" value="0" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-row layui-col-space10 layui-form-item">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-block">
                        <textarea name="content" class="layui-textarea" style="width: 100%;min-height:300px;">{$article.content}</textarea>
                    </div>
                </div>

                <div class="layui-form-item layui-layout-admin">
                    <div class="layui-input-block">
                        <div class="layui-footer" style="left: 0;">
                            <button class="layui-btn" lay-submit="" lay-filter="btnSave">保存</button>
                            <a class="layui-btn layui-btn-primary" href="javascript:parent.location.reload();">返回</a>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
{/block}

{block name="script"}
<script>

    layui.config({
        base: '__STATIC__/layuiadmin/' //静态资源所在路径
    }).extend({
        index: '/lib/index' //主入口模块
    }).use(['index', 'table', 'jquery', 'layer', 'form'], function () {
        var $ = layui.$, form = layui.form;

        form.on('radio(istop)', function(data){
            var value=data.value; //被点击的radio的value值
            if (value==1)
            {
                layer.tips('请输入封顶金额', '#topMoney',{tips: 1});
                $('#topMoney').attr("readOnly",false);
            }
            else
            {	$('#topMoney').val(0);
                $('#topMoney').attr("readOnly",true);
            }
        });
        form.on('submit(btnSave)', function (data) {
            $.post("{:url('edit')}", data.field, function (result) {
                console.log(result);
                if (result['code'] == 0) {
                    layer.msg(result['msg'], {icon: 1, time: 1000}, function () {
                        parent.location.reload();
                    });
                } else {
                    layer.msg(result['msg'], {icon: 3, time: 3000});
                }
            });
            return false;
        });
    });

</script>
{/block}